Component({
  mixins: [],
  data: {
    currIndex: 0,
    scrolllength: 0,
    show: true,
    onChangeFunc: null,
  },
  props: {},
  didMount() {
    this.setData({
      item: this.props.data,
      tabHeadLength: this.props.data.title.children.length,
      tabHeadWidth: this.props.data.title.style.scrollWidth,
    })
  },
  didUpdate() {

  },
  didUnmount() {

  },
  methods: {
    onTabChange(func) {
      this.setData({
        onChangeFunc: func
      })
    },
    onTabChangeIndex(event) {
      console.log(event.currentTarget.dataset['index'])
      this.setData({
        currIndex: event.currentTarget.dataset['index'],
        flag: true
      }, () => {
        this.scroll()
      })
      try {
        this.data.onChangeFunc(event.currentTarget.dataset['index'])
      } catch (e) {

      }
    },
    scroll() {
      let { item, currIndex } = this.data
      let scrollLeft = parseInt(item.title['children'][0]['style']['width']);
      let currScrollLeft = scrollLeft * (currIndex - 1) > 0 ? scrollLeft * (currIndex - 1) : 0
      this.setData({
        scrolllength: currScrollLeft
      })
    }
  },
});
